# _*_ coding:utf-8 _*_
from django.db import models

#部门表
class Department(models.Model):
    DepartmentID = models.CharField(max_length=40)
    DepartmentName = models.CharField(max_length=30)

#用户类型
class UserTypes(models.Model):
    UserTypeID = models.PositiveSmallIntegerField()
    UserTypeName = models.CharField(max_length=20)

#用户表
class Users(models.Model):
    UserID = models.CharField(max_length=40)
    UserName = models.CharField(max_length=20)
    Psw = models.CharField(max_length=20)
    Departments = models.ForeignKey(Department)
    #1代表超级管理员，2代表研发支持部管理员，3代表部门管理员，4代表普通人员
    UserType = models.ForeignKey(UserTypes) 

#服务器表
class Server(models.Model):
    ServerID = models.CharField(max_length=40)
    ServerIP = models.IPAddressField()
    ServerType = models.PositiveSmallIntegerField()
    SystemType = models.PositiveSmallIntegerField()
    Environment = models.PositiveSmallIntegerField()
    Program = models.CharField(max_length=100)

#申请表
class ApplyForm(models.Model):
    ApplyFormID = models.CharField(max_length=40)
    User = models.ForeignKey(Users)
    ApplyTime = models.DateTimeField(auto_now=True)
    ServerType = models.PositiveSmallIntegerField()
    SuseLinux = models.PositiveSmallIntegerField()
    Aix = models.PositiveSmallIntegerField()
    Windows = models.PositiveSmallIntegerField()
    Environment = models.PositiveSmallIntegerField()
    Reason = models.CharField(max_length=200)
    Program = models.CharField(max_length=100)

#审批历史表
class ApproveHistory(models.Model):
    ApproveHistoryID = models.CharField(max_length=40)
    ApplyForm = models.ForeignKey(ApplyForm)
    User = models.ForeignKey(Users)
    ApproveTime = models.DateTimeField()
    ApproveResult = models.PositiveSmallIntegerField()
    ApproveNote = models.CharField(max_length=200)





